home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 037a / mou_rout.zip / TEST.C < prev    next >
C/C++ Source or Header  |  1991-01-08  |  3KB  |  90 lines

  1. /*****************************************************************************
  2.  * PROJECT:  Mouse routines with 'real' graphic cursor in text mode.
  3.  *****************************************************************************
  4.  * MODULE:  TEST.C
  5.  *****************************************************************************
  6.  * DESCRIPTION:
  7.  *   Test program.
  8.  *
  9.  *****************************************************************************
  10.  * MODIFICATION NOTES:
  11.  *    Date     Author Comment
  12.  * 26-Oct-1990     dk   Initial file.
  13.  * 07-Jan-1991     dk   Fixed bugs and set up for release to Usenet.
  14.  *****************************************************************************
  15.  *
  16.  * DISCLAIMER:
  17.  *
  18.  * Programmers may incorporate any or all code into their programs, 
  19.  * giving proper credit within the source. Publication of the 
  20.  * source routines is permitted so long as proper credit is given 
  21.  * to Dave Kirsch.
  22.  *
  23.  * Copyright (C) 1990, 1991 by Dave Kirsch.  You may use this program, or
  24.  * code or tables extracted from it, as desired without restriction.
  25.  * I can not and will not be held responsible for any damage caused from
  26.  * the use of this software.
  27.  *
  28.  *****************************************************************************
  29.  * This source works with Turbo C 2.0 and MSC 6.0 and above.
  30.  *****************************************************************************/
  31.  
  32. #include <stdio.h>
  33.  
  34. #include "mou.h"
  35.  
  36. MOUINFOREC m;
  37.  
  38. int main(void)
  39. {
  40. int oldmx = -1, oldmy = -1;
  41.  
  42.   MOUinit();
  43.   MOUshow();
  44.  
  45.   if (!mouseinstalled) {
  46.     printf("Please install your mouse driver before running this test "
  47.        "program.\n");
  48.     return 0;
  49.   }
  50.  
  51.   MOUhide();
  52.   printf("\x1b[2J"); /* Clear the screen with ANSI code. */
  53.  
  54.   printf("\x1b[5;1HClick here [■] with left mouse button to quit.");
  55.   printf("\x1b[7;1HMouse routine demonstration program.");
  56.   printf("\x1b[8;1HWith 'true' EGA/VGA mouse cursor.");
  57.   printf("\x1b[9;1HCopyright (C) 1990, 1991 by Dave Kirsch.");
  58.   MOUshow();
  59.  
  60.   for (;;) {
  61.     if (mousex != oldmx || mousey != oldmy) {
  62.       oldmx = mousex;
  63.       oldmy = mousey;
  64.       MOUconditionalhide(0, 0, 50, 0);
  65.       printf("\x1b[1;1HMouse position: %3d, %3d", mousex, mousey);
  66.       MOUshow();
  67.     }
  68.  
  69.     if (MOUcheck()) { /* If mouse event waiting in buffer... */
  70.       MOUget(&m);
  71.       MOUconditionalhide(0, 1, 50, 2);
  72.       if (m.buttonstat & LEFTBPRESS)
  73.     printf("\x1b[2;1HLeft button pressed at %3d, %3d ", m.cx, m.cy);
  74.       if (m.buttonstat & LEFTBRELEASE)
  75.     printf("\x1b[2;1HLeft button released at %3d, %3d", m.cx, m.cy);
  76.       if (m.buttonstat & RIGHTBPRESS)
  77.     printf("\x1b[3;1HRight button pressed at %3d, %3d ", m.cx, m.cy);
  78.       if (m.buttonstat & RIGHTBRELEASE)
  79.     printf("\x1b[3;1HRight button released at %3d, %3d", m.cx, m.cy);
  80.       MOUshow();
  81.  
  82.       if (m.buttonstat & LEFTBPRESS && m.cx > 11 && m.cx < 14 && m.cy == 4) {
  83.     MOUdeinit();
  84.     printf("\x1b[2J"); /* Clear the screen with ANSI code. */
  85.     return 0;
  86.       }
  87.     }
  88.   }
  89. }
  90.